// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ManageSettingsActionHandler.cs" company="Roman '4ux-nbIx' Novitsky">
//   Copyright (c) Roman '4ux-nbIx' Novitsky 2009
// </copyright>
// <summary>
//   Describes and manipulates the show settings selector action.
// </summary>
// --------------------------------------------------------------------------------------------------------------------


namespace SettingsManager
{
    #region Namespace Imports

    using JetBrains.ActionManagement;

    #endregion


    /// <summary>
    /// Describes and manipulates the show settings selector action.
    /// </summary>
    [ActionHandler(new[] { "RSM.ManageSettings" })]
    internal class ManageSettingsActionHandler : IActionHandler
    {
        #region Public Methods

        /// <summary>
        /// Executes action. Called after Update, that set <see cref="ActionPresentation"/>.Enabled to <c>true</c>.
        /// </summary>
        /// <param name="context">
        /// An instance of <see cref="IDataContext"/>.
        /// </param>
        /// <param name="nextExecute">
        /// Delegate to call.
        /// </param>
        public void Execute(IDataContext context, DelegateExecute nextExecute)
        {
            ResharperSettingsManager settingsManager = ResharperSettingsManager.Instance;

            var manageSettingsForm = new ManageSettingsForm(context) { SettingsManager = settingsManager };

            manageSettingsForm.ShowDialog();

            manageSettingsForm.Dispose();
        }


        /// <summary>
        /// Updates action visual presentation. If presentation.Enabled is set to <c>false</c>, Execute
        /// will not be called.
        /// </summary>
        /// <param name="context">
        /// An instance of <see cref="IDataContext"/>.
        /// </param>
        /// <param name="presentation">
        /// Presentation to update.
        /// </param>
        /// <param name="nextUpdate">
        /// Delegate to call.
        /// </param>
        /// <returns>
        /// True is the menu item should be shown.
        /// </returns>
        public bool Update(IDataContext context, ActionPresentation presentation, DelegateUpdate nextUpdate)
        {
            return true;
        }

        #endregion
    }
}